/*
 * Project: Set Sample
 * Copyright (C) 2013 alf.labs gmail com,
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.alflabs.setsample.stats;

public class SetResult {
    private int mLevel;
    private long mBoardTimeMs;
    private long mFastestTimeMs;
    private long mAvgTimeMs;
    private boolean mNewFastest;

    public SetResult(int level, boolean newFastest, long boardTimeMs, long fastestTimeMs, long avgTimeMs) {
        mLevel = level;
        mNewFastest = newFastest;
        mBoardTimeMs = boardTimeMs;
        mFastestTimeMs = fastestTimeMs;
        mAvgTimeMs = avgTimeMs;
    }

    public int getLevel() {
        return mLevel;
    }

    public boolean isNewFastest() {
        return mNewFastest;
    }

    public long getBoardTimeMs() {
        return mBoardTimeMs;
    }

    public long getFastestTimeMs() {
        return mFastestTimeMs;
    }

    public long getAvgTimeMs() {
        return mAvgTimeMs;
    }

    @Override
    public String toString() {
        return "SetResult{" +
                "mLevel=" + mLevel +
                ", mBoardTimeMs=" + mBoardTimeMs +
                ", mFastestTimeMs=" + mFastestTimeMs +
                ", mAvgTimeMs=" + mAvgTimeMs +
                ", mNewFastest=" + mNewFastest +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SetResult setResult = (SetResult) o;

        if (mAvgTimeMs != setResult.mAvgTimeMs) return false;
        if (mBoardTimeMs != setResult.mBoardTimeMs) return false;
        if (mFastestTimeMs != setResult.mFastestTimeMs) return false;
        if (mLevel != setResult.mLevel) return false;
        //noinspection RedundantIfStatement
        if (mNewFastest != setResult.mNewFastest) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = mLevel;
        result = 31 * result + (int) (mBoardTimeMs ^ (mBoardTimeMs >>> 32));
        result = 31 * result + (int) (mFastestTimeMs ^ (mFastestTimeMs >>> 32));
        result = 31 * result + (int) (mAvgTimeMs ^ (mAvgTimeMs >>> 32));
        result = 31 * result + (mNewFastest ? 1 : 0);
        return result;
    }
}
